
import random
import C02D205

def search(list,object):
    lo=0
    hi=len(list)
    while(1<(hi-lo)):
        mid=(lo+hi)>>1
        if object<list[mid]:
            hi=mid
        else:
            lo=mid
    if list[lo]==object:
        return lo
    else:
        return -1

def main():
    testArray=[]
    while len(testArray)<20:
        testArray.append(random.randint(0,100))
    C02D205.sortArray(testArray)
    print(testArray)
    result=search(testArray,testArray[10])
    print(result)
    # search([0,1,2],1)



if __name__=="__main__":
    main()